package com.jshare.service.Impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jshare.dao.TieziDAO;
import com.jshare.dao.TzReplyDAO;
import com.jshare.entity.Tiezi;
import com.jshare.entity.TzReply;
import com.jshare.tiezi.use.fenye.PageInfo;
import com.jshare.tiezi.use.fenye.PageInfoDao;

@Service("tieziService")
public class TieziServiceImpl implements com.jshare.service.TieziService {
	@Resource(name="tieziDao")
	private TieziDAO tieziDao;
	@Resource(name="pageInfoDao")
	private PageInfoDao pageInfoDao;
	@Resource(name="tzReplyDao")
	private TzReplyDAO tzReplyDao;
	

	public TzReplyDAO getTzReplyDao() {
		return tzReplyDao;
	}

	public void setTzReplyDao(TzReplyDAO tzReplyDao) {
		this.tzReplyDao = tzReplyDao;
	}

	public PageInfoDao getPageInfoDao() {
		return pageInfoDao;
	}

	public void setPageInfoDao(PageInfoDao pageInfoDao) {
		this.pageInfoDao = pageInfoDao;
	}

	public TieziDAO getTieziDao() {
		return tieziDao;
	}

	public void setTieziDao(TieziDAO tieziDao) {
		this.tieziDao = tieziDao;
	}

	public void addTiezi(Tiezi tie) {
		tieziDao.save(tie);
	}
	
	public List<Tiezi> getAllTies(){
		return tieziDao.findAll();
	}

	public PageInfo getAllTiesByFenye(int curPage, int pageSize, String sql) {
		PageInfo info = pageInfoDao.getPageInfo(curPage, pageSize, sql);
		return info;
	}

	public Tiezi findById(Integer id) {
		return tieziDao.findById(id);
	}

	public void addTzReply(TzReply tr) {
		tzReplyDao.save(tr);
	}

	public PageInfo getSingleTieAndReply(int curPage, int pageSize,
			Integer tiezi_id) {
		PageInfo info = pageInfoDao.getPageInfo(curPage, pageSize, tiezi_id);
		return info;
	}

}
